﻿using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace Mengsk.ProxyDelivery.Converters
{
    public class OrderChangeImageCountConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            OrderChange oc = value as OrderChange;
            if (oc == null)
            {
                return "没有图片";
            }
            int count = 0;

            if ("SellerImage".Equals(parameter))
            {
                if (string.IsNullOrWhiteSpace(oc.SellerImage1)==false)
                {
                    count++;
                }
                if (string.IsNullOrWhiteSpace(oc.SellerImage2)==false)
                {
                    count++;
                }
                if (string.IsNullOrWhiteSpace(oc.SellerImage3)==false)
                {
                    count++;
                }
            }
            else
            {
                if (string.IsNullOrWhiteSpace(oc.SystemImage1)==false)
                {
                    count++;
                }
                if (string.IsNullOrWhiteSpace(oc.SystemImage2)==false)
                {
                    count++;
                }
                if (string.IsNullOrWhiteSpace(oc.SystemImage3)==false)
                {
                    count++;
                }
            }

            if (count == 0)
            {
                return "没有图片";
            }

            return "查看图片(" + count + ")";

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
